# 将标签图从json文件中批量取出
import os
import shutil

path = r'E:/dataset/new_car/'
dirpath = r'/dataset/new_car/labels/'

for eachfile in os.listdir(path):
    if os.path.isdir(path + eachfile):
        if os.path.exists(path + eachfile + '/label.png'):
            shutil.copy(path + eachfile + '/label.png', dirpath + eachfile.split('_')[0] + '.png')
            print(eachfile + ' successfully moved')
